import { getToken } from '@/utils/auth'
import { getSingleData } from '@/api/my/xuanti'

const user = {
  state: {
    token: getToken(),
    xuantiEdit: []
  },

  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    XUANTI: (state, list) => {
      state.xuantiEdit = list
    }
  },

  actions: {
    // 登录
    // Login({ commit }, userInfo) {
    //   const phoneNumber = userInfo.phoneNumber
    //   const sendType = userInfo.sendType
    //   const code = userInfo.code
    //   const uuid = userInfo.uuid
    //   const smsCode=userInfo.smsCode
    //   return new Promise((resolve, reject) => {
    //     login(phoneNumber, sendType, code, uuid,smsCode).then(res => {
    //       setToken(res.token)
    //       commit('SET_TOKEN', res.token)
    //       resolve()
    //     }).catch(error => {
    //       reject(error)
    //     })
    //   })
    // },

    //action
    async getXuantiEdit({ commit }, id) {
      let res = await getSingleData(id)
      if (res.code == 200) {
        commit('XUANTI', res.data)
        //console.log(res);
        return res.code
      }
    }

  }
}

export default user
